import 'package:json_annotation/json_annotation.dart';

part 'user_card.g.dart';

@JsonSerializable()
class UserCard {
  final List<CardList> cards;

  UserCard({this.cards});

  factory UserCard.fromJson(Map<String, dynamic> json) =>
      _$UserCardFromJson(json);

  Map<String, dynamic> toJson() => _$UserCardToJson(this);
}

@JsonSerializable()
class CardList {
  final CardInfo card;
  final CardLevel cardLevel;
  final int fightingCapacity;

  CardList({this.card, this.cardLevel, this.fightingCapacity});

  factory CardList.fromJson(Map<String, dynamic> json) =>
      _$CardListFromJson(json);

  Map<String, dynamic> toJson() => _$CardListToJson(this);
}

@JsonSerializable()
class CardLevel {
  final int id;
  final String cardId;
  final int level;
  final int hp;
  final int atk;
  final int def;
  final int res;
  final List<HarvestInfo> prerequisite;
  final List<HarvestInfo> consumables;
  final String updateTime;

  CardLevel(
      {this.id,
      this.cardId,
      this.level,
      this.hp,
      this.atk,
      this.def,
      this.res,
      this.prerequisite,
      this.consumables,
      this.updateTime});

  factory CardLevel.fromJson(Map<String, dynamic> json) =>
      _$CardLevelFromJson(json);

  Map<String, dynamic> toJson() => _$CardLevelToJson(this);
}

@JsonSerializable()
class CardInfo {
  final int id;
  final String cardId;
  final String name;
  final String operatorName;
  final String description;
  final int classesId;
  final String professionName;
  final int quality;
  final int maxLevel;
  final List<HarvestInfo> harvest;
  final String updateTime;
  final int level;
  final int num;
  final String sources;
  final String picUrlSmall;
  final String picUrlBig;

  CardInfo({
    this.id,
    this.cardId,
    this.name,
    this.operatorName,
    this.description,
    this.classesId,
    this.professionName,
    this.quality,
    this.maxLevel,
    this.harvest,
    this.updateTime,
    this.level,
    this.sources,
    this.picUrlSmall,
    this.picUrlBig,
    this.num,
  });

  factory CardInfo.fromJson(Map<String, dynamic> json) =>
      _$CardInfoFromJson(json);

  Map<String, dynamic> toJson() => _$CardInfoToJson(this);
}

@JsonSerializable()
class HarvestInfo {
  final int type;
  final String id;
  final int value;

  HarvestInfo({this.type, this.id, this.value});

  factory HarvestInfo.fromJson(Map<String, dynamic> json) =>
      _$HarvestInfoFromJson(json);

  Map<String, dynamic> toJson() => _$HarvestInfoToJson(this);
}
